package playas;

/**
 * Created by IntelliJ IDEA.
 * User: avilches
 * Date: 07/05/11
 * Time: 20:45
 * To change this template use File | Settings | File Templates.
 */
public class Distancia {

    static double degtorad = 0.01745329;
    static double radtodeg = 57.29577951;
    static double toKM = 111.302;

    public static double distanciaGeodesica(double lat1, double long1, double lat2, double long2) {

        double dlong = long1 - long2;
        double dvalue = (Math.sin(lat1 * degtorad) * Math.sin(lat2 * degtorad))
                + (Math.cos(lat1 * degtorad) * Math.cos(lat2 * degtorad)
                * Math.cos(dlong * degtorad));

        double dd = Math.acos(dvalue) * radtodeg;


        double km = (dd * toKM);

        return km;
    }
}
